//
//  UIView.h
//  Meng800
//
//  Created by 姚宗超 on 14-7-23.
//  Copyright (c) 2014年 点财网. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface UIView (Common)
#pragma mark - Borders
/**
 Creates and adds a border to any UIView. The border is inset - meaning the frame size stays the same, the border just takes up the innermost width parameter of the perimeter of the UIView.
 @param width   - float for number of pixels
 @param color   - UIColor
 */
- (void)addBorderWithWidth:(float)width color:(UIColor *)color;

- (void)setCornerRadius:(float)radius;

#pragma mark - Separator UIView
/**
 Creates a 1 pixel tall separtor of any color you'd like. The returned separator can stretch its width, but cannot stretch its height on rotation or resizing.
 @param width   - width of the returned separator
 @param origin  - CGPoint of the x,y coordinates ot begin
 @param color   - UIColor for the separator
 @return UIView - returns the view with the correct frame.
 */
+ (UIView *)separatorWithWidth:(float)width origin:(CGPoint)origin color:(UIColor *)color;

- (void)addBottomSeparatorWithLineWidth:(CGFloat)width color:(UIColor *)color padding:(CGFloat)padding; // 点财通用，底边分割线

- (void)addBottomSeparatorWithLineWidth:(CGFloat)width color:(UIColor *)color leftPadding:(CGFloat)lPadding rightPadding:(CGFloat)rPadding; // 点财通用，底边分割线

#pragma mark - UI Coordinate

/**
 * Shortcut for frame.origin.x.
 *
 * Sets frame.origin.x = left
 */
@property (nonatomic) CGFloat left;

/**
 * Shortcut for frame.origin.y
 *
 * Sets frame.origin.y = top
 */
@property (nonatomic) CGFloat top;

/**
 * Shortcut for frame.origin.x + frame.size.width
 *
 * Sets frame.origin.x = right - frame.size.width
 */
@property (nonatomic) CGFloat right;

/**
 * Shortcut for frame.origin.y + frame.size.height
 *
 * Sets frame.origin.y = bottom - frame.size.height
 */
@property (nonatomic) CGFloat bottom;

/**
 * Shortcut for frame.size.width
 *
 * Sets frame.size.width = width
 */
@property (nonatomic) CGFloat width;

/**
 * Shortcut for frame.size.height
 *
 * Sets frame.size.height = height
 */
@property (nonatomic) CGFloat height;

/**
 * Shortcut for center.x
 *
 * Sets center.x = centerX
 */
@property (nonatomic) CGFloat centerX;

/**
 * Shortcut for center.y
 *
 * Sets center.y = centerY
 */
@property (nonatomic) CGFloat centerY;

/**
 * Return the x coordinate on the screen.
 */
@property (nonatomic, readonly) CGFloat ttScreenX;

/**
 * Return the y coordinate on the screen.
 */
@property (nonatomic, readonly) CGFloat ttScreenY;

/**
 * Return the x coordinate on the screen, taking into account scroll views.
 */
@property (nonatomic, readonly) CGFloat screenViewX;

/**
 * Return the y coordinate on the screen, taking into account scroll views.
 */
@property (nonatomic, readonly) CGFloat screenViewY;

/**
 * Return the view frame on the screen, taking into account scroll views.
 */
@property (nonatomic, readonly) CGRect screenFrame;

/**
 * Shortcut for frame.origin
 */
@property (nonatomic) CGPoint origin;

/**
 * Shortcut for frame.size
 */
@property (nonatomic) CGSize size;

/**
 * Return the width in portrait or the height in landscape.
 */
@property (nonatomic, readonly) CGFloat orientationWidth;

/**
 * Return the height in portrait or the width in landscape.
 */
@property (nonatomic, readonly) CGFloat orientationHeight;

/**
 * Finds the first descendant view (including this view) that is a member of a particular class.
 */
- (UIView*)descendantOrSelfWithClass:(Class)cls;

/**
 * Finds the first ancestor view (including this view) that is a member of a particular class.
 */
- (UIView*)ancestorOrSelfWithClass:(Class)cls;

/**
 * Removes all subviews.
 */
- (void)removeAllSubviews;

@end
